﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Office2010.Excel;
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NP.BPMReportPlatform.Cadre.Dto;
using NP.BPMReportPlatform.Common.Dtos;
using NP.BPMReportPlatform.Contract.Dtos;
using NP.BPMReportPlatform.CourseTrain.Dtos;
using NP.BPMReportPlatform.CourseTrain.Enums;
using NP.BPMReportPlatform.Document;
using NP.BPMReportPlatform.Document.Dtos;
using NP.BPMReportPlatform.Entities.BPM_Business;
using NP.BPMReportPlatform.UserTrial.Dto;
using NPOI.HPSF;
using Volo.Abp.Application.Dtos;
using static NP.BPMReportPlatform.CourseTrain.Dtos.CourseReportDto;

namespace NP.BPMReportPlatform.CourseTrain
{
    /// <summary>
    /// 工程接口
    /// </summary>
    // [Authorize]
    [ApiController]
    [Route("api/course-train-task")]
    public class CourseTrainTaskController : BPMReportPlatformController
    {
        private readonly ICourseTrainTaskService _courseTrainTaskService;
        private readonly ICourseTrainTaskSyncJob _courseTrainTaskSyncJobService;

        public CourseTrainTaskController(ICourseTrainTaskService courseTrainTaskService, ICourseTrainTaskSyncJob courseTrainTaskSyncJobService)
        {
            _courseTrainTaskService = courseTrainTaskService;
            _courseTrainTaskSyncJobService = courseTrainTaskSyncJobService;
        }

        #region 国内任务单
        /// <summary>
        /// 获取任务单详情信息
        /// </summary>
        /// <param name="courseTrainTaskId">任务单号</param>
        /// <returns>任务单详情</returns>
        [HttpGet]
        [Route("TC/GetCourseTrainTaskData")]
        public async Task<CourseTrainTaskDto> GetCourseTrainTaskData([FromQuery] string courseTrainTaskId)
        {
            return await _courseTrainTaskService.GetCourseTrainTaskData(courseTrainTaskId);
        }

        /// <summary>
        /// 根据iLearaning获取培训人员明细数据
        /// </summary>
        /// <param name="data">请求参数</param>
        /// <returns>培训人员明细列表</returns>
        [HttpPost]
        [Route("TC/GetTrainUsers")]
        public async Task<List<CourseTrainUserDetailEntity>> GetTrainUsers([FromBody] Dictionary<string, List<string>> data)
        {
            return await _courseTrainTaskService.GetTrainUsers(data["iLearningCodes"]);
        }

        /// <summary>
        /// 培训任务单列表明细查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>培训任务单列表</returns>
        [HttpPost]
        [Route("TC/GetTrainTaskListResult")]
        public async Task<PagedResultPowerDto<GetTrainTaskOutput>> GetTrainTaskListResult([FromBody] GetTrainResultInput input)
        {
            return await _courseTrainTaskService.GetTrainTaskListResult(input);
        }

        /// <summary>
        /// 培训任务单列表明细查询数据批量导出
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TC/ExportTrainTaskListAsync")]
        public async Task<XlsxFileResult<GetTrainTaskOutput>> ExportTrainTaskListAsync([FromBody] GetTrainResultInput input)
        {
            input.PageSize = int.MaxValue;
            var rst = (await _courseTrainTaskService.GetTrainTaskListResult(input)).Items.ToList();
            var result = rst.Adapt<List<GetTrainTaskOutput>>();
            return new XlsxFileResult<GetTrainTaskOutput>(result, "培训任务单列表导出");
        }

        /// <summary>
        /// 根据工号获取培训人员明细数据
        /// </summary>
        /// <param name="data">请求参数</param>
        /// <returns>培训人员明细数据</returns>
        [HttpPost]
        [Route("TC/GetUserInfo")]
        public async Task<List<CourseTrainUserDetailEntity>> GetUserInfo([FromBody] Dictionary<string, List<string>> data)
        {
            return await _courseTrainTaskService.GetUserInfo(data["workNumbers"]);
        }

        /// <summary>
        /// 提交任务单数据
        /// </summary>
        /// <param name="data">请求参数</param>
        /// <returns>返回消息</returns>
        [HttpPost]
        [Route("TC/Submit")]
        public async Task<IActionResult> Submit(CourseTrainTaskDto data)
        {
            var result = await _courseTrainTaskService.CourseTrainTaskSave(data, true);
            if (!result.Result)
            {
                return BadRequest(result.Msg);
            }
            else
            {
                await _courseTrainTaskSyncJobService.SendCourseEmail(CourseTrainEmailEnum.培训考证附件上传前, data.BaseData.CourseTrainTaskId);

            }

            return Ok();
        }


        /// <summary>
        /// 提交任务单数据
        /// </summary>
        /// <param name="data">请求参数</param>
        /// <returns>返回消息</returns>
        [HttpPost]
        [Route("TC/Save")]
        public async Task<IActionResult> Save(CourseTrainTaskDto data)
        {
            var result = await _courseTrainTaskService.CourseTrainTaskSave(data, false);
            if (!result.Result)
            {
                return BadRequest(result.Msg);
            }

            return Ok();
        }

        /// <summary>
        /// 变更任务单状态
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="status">status</param>
        /// <returns>返回消息</returns>
        [HttpGet]
        [Route("TC/{id}/{status}")]
        public async Task<IActionResult> UpdateStatus([FromRoute] string id, [FromRoute] int status)
        {
            await _courseTrainTaskService.UpdateStatus(id, status);
            if (CourseTrainTaskStatusEnum.培训完成.GetHashCode() == status)
            {
                await _courseTrainTaskSyncJobService.SendCourseEmail(CourseTrainEmailEnum.培训考证附件上传前, id);
            }
            return Ok();
        }
        #endregion
        #region 海外培训计划
        /// <summary>
        /// 海外培训任务单列表明细查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>培训任务单列表</returns>
        [HttpPost]
        [Route("TOS/GetTrainOverSeaListResult")]
        public async Task<PagedResultPowerDto<GetTrainOverSeaOutput>> GetTrainOverSeaListResult([FromBody] GetTrainResultInput input)
        {
            return await _courseTrainTaskService.GetTrainOverSeaListResult(input);
        }

        /// <summary>
        /// 海外培训任务单列表明细查询数据批量导出
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TOS/ExportTrainTaskListAsync")]
        public async Task<XlsxFileResult<GetTrainOverSeaOutput>> ExportTrainOverSeaListtAsync([FromBody] GetTrainResultInput input)
        {
            input.PageSize = int.MaxValue;
            var rst = (await _courseTrainTaskService.GetTrainOverSeaListResult(input)).Items.ToList();
            var result = rst.Adapt<List<GetTrainOverSeaOutput>>();
            return new XlsxFileResult<GetTrainOverSeaOutput>(result, "海外培训任务单列表导出");
        }

        /// <summary>
        /// 获取海外任务单详情信息
        /// </summary>
        /// <param name="courseId">任务单号</param>
        /// <returns>任务单详情</returns>
        [HttpGet]
        [Route("TOS/GetCourseOverSeaData")]
        public async Task<CourseOverSeaDto> GetCourseOverSeaData([FromQuery] string courseId)
        {
            return await _courseTrainTaskService.GetCourseOverSeaData(courseId);
        }


        /// <summary>
        /// 提交培训心得，总结
        /// </summary>
        /// <param name="courseSummary">心得总结数据</param>
        [HttpPost]
        [Route("TOS/SummarySubmit")]
        public async Task<ActionResult> SummarySubmit(CourseSummaryEntity courseSummary)
        {
            var result = await _courseTrainTaskService.SummarySubmit(courseSummary);
            return result.Result ? Ok() : BadRequest(result.Msg);
        }

        /// <summary>
        /// 变更海外任务单状态
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="status">status</param>
        /// <returns>返回消息</returns>
        [HttpGet]
        [Route("TOS/{id}/{status}")]
        public async Task<IActionResult> UpdateOverSeaStatus([FromRoute] string id, [FromRoute] int status)
        {
            var result = await _courseTrainTaskService.UpdateOverSeaStatus(id, status);
            if (result.Result && CourseTrainTaskStatusEnum.培训完成.GetHashCode() == status)
            {
                await _courseTrainTaskSyncJobService.SendCourseEmail(CourseTrainEmailEnum.海外培训审批通过提醒签协议, id);
            }
            return result.Result ? Ok() : BadRequest(result.Msg);
        }

        /// <summary>
        /// 更新护照信息
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="value">号码</param>
        /// <returns>返回消息</returns>
        [HttpGet]
        [Route("TOS/UpdatePortNumber/{id}/{value}")]
        public async Task<IActionResult> UpdatePortNumber([FromRoute] string id, [FromRoute] string value)
        {
            var result = await _courseTrainTaskService.UpdatePortNumber(id, value);
            return result.Result ? Ok() : BadRequest(result.Msg);
        }
        #endregion
        #region iLearning相关
        /// <summary>
        /// 同步iLearning课程信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("TC/SyncTrainCourses")]
        public async Task SyncTrainCourses()
        {
            await _courseTrainTaskService.SyncTrainCourses();
        }

        /// <summary>
        /// 同步iLearning讲师数据
        /// </summary>
        [HttpGet]
        [Route("TC/SyncInstractor")]
        public async Task SyncInstractor()
        {
            await _courseTrainTaskService.SyncInstractor();
        }

        /// <summary>
        /// 获取ILearning选项
        /// </summary>
        /// <returns>任务单详情</returns>
        [HttpGet]
        [Route("TC/GetILearningOptions")]
        public async Task<List<ItemPairDto>> GetILearningOptions()
        {
            return await _courseTrainTaskService.GetILearningOptions();
        }

        #endregion
        #region 培训考证管理
        /// <summary>
        /// 获取培训考证列表数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>培训考证列表数据</returns>
        [HttpPost]
        [Route("CERT/GetCourseCertListResult")]
        public async Task<PagedResultPowerDto<GetCourseCertOutput>> GetCourseCertListResult([FromBody] GetTrainResultInput input)
        {
            return await _courseTrainTaskService.GetCourseCertListResult(input);
        }

        /// <summary>
        /// 获取培训考证列表数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>培训考证列表数据</returns>
        [HttpPost]
        [Route("CERT/ExportAsync")]
        public async Task<XlsxFileResult<GetCourseCertOutput>> ExportCourseCertListResult([FromBody] GetTrainResultInput input)
        {
            input.PageSize = int.MaxValue;
            var rst = (await _courseTrainTaskService.GetCourseCertListResult(input)).Items.ToList();
            var result = rst.Adapt<List<GetCourseCertOutput>>();
            return new XlsxFileResult<GetCourseCertOutput>(result, "获取培训考证列表列表导出");
        }

        /// <summary>
        /// 上传证书文件
        /// </summary>
        /// <param name="file">file</param>
        /// <param name="courseTrainUserDetailId">明细id</param>
        /// <returns></returns>
        [HttpPost]
        [Route("CERT/Upload")]
        public async Task<IActionResult> UploadCert(IFormFile file, [FromQuery] string courseTrainUserDetailId)
        {
            if (file == null || file.Length == 0)
            {
                return BadRequest("No file selected.");
            }

            var stream = file.OpenReadStream();

            byte[] bytes;
            using (var memoryStream = new MemoryStream())
            {
                file.CopyTo(memoryStream);
                bytes = memoryStream.ToArray();
            }
            stream.Close();

            var result = await _courseTrainTaskService.UploadCert(bytes, file.FileName, courseTrainUserDetailId);

            if (result.Result)
            {
                await _courseTrainTaskSyncJobService.SendCourseEmail(CourseTrainEmailEnum.培训考证附件上传后, courseTrainUserDetailId);
            }

            return result.Result ? Ok(JsonConvert.DeserializeObject<List<DocumentDto>>(result.Msg)) : BadRequest(result.Msg);
        }

        /// <summary>
        /// 更新证书截止日期
        /// </summary>
        /// <param name="endDate">截止日期</param>
        /// <param name="courseTrainUserDetailId">明细id</param>
        /// <returns></returns>
        [HttpGet]
        [Route("CERT/CertEndDate/{courseTrainUserDetailId}/{endDate}")]
        public async Task<IActionResult> CertEndDate([FromRoute] string courseTrainUserDetailId, [FromRoute] DateTime endDate)
        {
            await _courseTrainTaskService.CertEndDate(courseTrainUserDetailId, endDate);
            return Ok();
        }

        /// <summary>
        /// 更新证书截止日期
        /// </summary>
        /// <param name="status">状态</param>
        /// <param name="courseTrainUserDetailId">明细id</param>
        /// <returns></returns>
        [HttpGet]
        [Route("CERT/CertUpdateStatus/{courseTrainUserDetailId}/{status}")]
        public async Task<IActionResult> CertUpdateStatus([FromRoute] string courseTrainUserDetailId, [FromRoute] int status)
        {
            await _courseTrainTaskService.CertUpdateStatus(courseTrainUserDetailId, status);
            return Ok();
        }


        #endregion
        #region 讲师
        /// <summary>
        /// 讲师列表明细查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>讲师列表明细查询数据</returns>
        [HttpPost]
        [Route("TC/GetCourseInstructorList")]
        public async Task<PagedResultPowerDto<GetCourseInstructorOutput>> GetCourseInstructorList([FromBody] GetCourseItemInput input)
        {
            return await _courseTrainTaskService.GetCourseInstructorList(input);
        }

        /// <summary>
        /// 讲师项目使用情况明细查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>讲师列表明细查询数据</returns>
        [HttpPost]
        [Route("ReportInstructor/GetCourseInstructorUseList")]
        public async Task<PagedResultPowerDto<GetInstructorUseSummaryOutput>> GetCourseInstructorUseList([FromBody] GetTrainResultInput input)
        {
            return await _courseTrainTaskService.GetCourseInstructorUseList(input);
        }

        /// <summary>
        /// 新增或者更新培训讲师数据
        /// </summary>
        /// <param name="input"></param>
        [HttpPost]
        [Route("TC/AddOrUpdateCourseInstructor")]
        public async Task AddOrUpdateCourseInstructor([FromBody] CourseInstructorEntity input)
        {
            await _courseTrainTaskService.AddOrUpdateCourseInstructor(input);
        }

        /// <summary>
        /// 更新培训讲师状态
        /// </summary>
        /// <param name="courseInstructorId">主键</param>
        /// <param name="status">状态</param>
        [HttpGet]
        [Route("TC/UpdateCourseInstructorStatus/{courseInstructorId}/{status}")]
        public async Task UpdateCourseInstructorStatus([FromRoute] string courseInstructorId, int status)
        {
            await _courseTrainTaskService.UpdateCourseInstructorStatus(courseInstructorId, status);
        }

        /// <summary>
        /// 删除培训讲师数据
        /// </summary>
        /// <param name="courseInstructorId">主键</param>
        [HttpDelete]
        [Route("TC/CourseInstructor/{courseInstructorId}")]
        public async Task DeleteCourseInstructor([FromRoute] string courseInstructorId)
        {
            await _courseTrainTaskService.DeleteCourseInstructor(courseInstructorId);
        }

        /// <summary>
        /// 培训讲师数据 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TC/ExportCourseInstructorResultAsync")]
        public async Task<XlsxFileResult<GetCourseInstructorOutput>> ExportCourseInstructorResultAsync([FromBody] GetCourseItemInput input)
        {
            input.PageSize = int.MaxValue;
            var rst = await _courseTrainTaskService.ExportCourseInstructorResultAsync(input);
            return new XlsxFileResult<GetCourseInstructorOutput>(rst, "导出Excel");
        }

        /// <summary>
        /// 培训讲师使用明细数据 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ReportInstructor/ExportCourseInstructorUseListAsync")]
        public async Task<XlsxFileResult<GetInstructorUseSummaryOutput>> ExportCourseInstructorUseListAsync([FromBody] GetTrainResultInput input)
        {
            var rst = await _courseTrainTaskService.ExportCourseInstructorUseListAsync(input);
            return new XlsxFileResult<GetInstructorUseSummaryOutput>(rst, "导出Excel");
        }

        /// <summary>
        /// 获取讲师下拉选项
        /// </summary>
        [HttpGet]
        [Route("TC/GetInstructorOptions")]
        public async Task<List<ItemPairDto>> GetInstructorOptions()
        {
            return await _courseTrainTaskService.GetInstructorOptions();
        }
        #endregion
        #region 境外来华清单
        /// <summary>
        /// 查询境外来华清单数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>境外来华明细查询数据</returns>
        [HttpPost]
        [Route("AB/GetCourseAbToChinaList")]
        public async Task<PagedResultPowerDto<GetCourseAbToChinaOutput>> GetCourseAbToChinaList([FromBody] GetCourseAbToChinaInput input)
        {
            return await _courseTrainTaskService.GetCourseAbToChinaList(input);
        }

        /// <summary>
        /// 新增或者更新境外来华清单数据
        /// </summary>
        /// <param name="input"></param>
        [HttpPost]
        [Route("AB/AddOrUpdateCourseAbroadToChina")]
        public async Task AddOrUpdateCourseAbroadToChina(CourseAbroadToChinaEntity input)
        {
            await _courseTrainTaskService.AddOrUpdateCourseAbroadToChina(input);
        }

        /// <summary>
        /// 删除境外来华清单数据
        /// </summary>
        /// <param name="abroadId">主键</param>
        [HttpDelete]
        [Route("AB/CourseAbroad/{abroadId}")]
        public async Task DeleteAbroadToChina(string abroadId)
        {
            await _courseTrainTaskService.DeleteAbroadToChina(abroadId);
        }

        /// <summary>
        /// 海外来华任务单 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("AB/ExportCourseAbToChinaListAsync")]
        public async Task<XlsxFileResult<GetCourseAbToChinaOutput>> ExportCourseAbToChinaListAsync([FromBody] GetCourseAbToChinaInput input)
        {
            var rst = await _courseTrainTaskService.ExportCourseAbToChinaListAsync(input);
            return new XlsxFileResult<GetCourseAbToChinaOutput>(rst, "导出Excel");
        }

        /// <summary>
        /// 导入海外来华任务数据
        /// </summary>
        /// <param data="导入数据"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("AB/ImportAbroadUsers")]
        [Obsolete("不做啦，暂时废弃")]
        public async Task<ActionResult> ImportAbroadUsersAsync(List<CourseAbroadToChinaEntity> data)
        {
            await _courseTrainTaskService.ImportAbroadUsersAsync(data);
            return Ok();
        }
        #endregion
        #region 项目
        /// <summary>
        /// 项目列表明细查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>项目列表明细查询数据</returns>
        [HttpPost]
        [Route("TC/GetCourseProjectList")]
        public async Task<PagedResultPowerDto<GetCourseProjectOutput>> GetCourseProjectList([FromBody] GetCourseItemInput input)
        {
            return await _courseTrainTaskService.GetCourseProjectList(input);
        }

        /// <summary>
        /// 新增或者更新培训项目数据
        /// </summary>
        /// <param name="input"></param>
        [HttpPost]
        [Route("TC/AddOrUpdateCourseProject")]
        public async Task AddOrUpdateCourseProject([FromBody] CourseProjectEntity input)
        {
            await _courseTrainTaskService.AddOrUpdateCourseProject(input);
        }

        /// <summary>
        /// 更新培训项目状态
        /// </summary>
        /// <param name="courseProjectId">主键</param>
        /// <param name="status">状态</param>
        [HttpGet]
        [Route("TC/UpdateCourseProjectStatus/{courseProjectId}/{status}")]
        public async Task UpdateCourseProjectStatus([FromRoute] string courseProjectId, int status)
        {
            await _courseTrainTaskService.UpdateCourseProjectStatus(courseProjectId, status);
        }

        /// <summary>
        /// 删除培训项目数据
        /// </summary>
        /// <param name="courseProjectId">主键</param>
        [HttpDelete]
        [Route("TC/CourseProject/{courseProjectId}")]
        public async Task DeleteCourseProject([FromRoute] string courseProjectId)
        {
            await _courseTrainTaskService.DeleteCourseProject(courseProjectId);
        }

        /// <summary>
        /// 培训项目数据 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TC/ExportCourseProjectResultAsync")]
        public async Task<XlsxFileResult<GetCourseProjectOutput>> ExportCourseProjectResultAsync([FromBody] GetCourseItemInput input)
        {
            var rst = await _courseTrainTaskService.ExportCourseProjectResultAsync(input);
            return new XlsxFileResult<GetCourseProjectOutput>(rst, "导出Excel");
        }

        /// <summary>
        /// 获取项目下拉选项
        /// </summary>
        [HttpGet]
        [Route("TC/GetProjectOptions")]
        public async Task<List<ItemPairDto>> GetProjectOptions()
        {
            return await _courseTrainTaskService.GetProjectOptions();
        }
        #endregion
        #region 课程
        /// <summary>
        /// 课程列表明细查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns>课程列表明细查询数据</returns>
        [HttpPost]
        [Route("TC/GetCourseManageList")]
        public async Task<PagedResultPowerDto<GetCourseManageOutput>> GetCourseManageList([FromBody] GetCourseItemInput input)
        {
            return await _courseTrainTaskService.GetCourseManageList(input);
        }

        /// <summary>
        /// 新增或者更新培训课程数据
        /// </summary>
        /// <param name="input"></param>
        [HttpPost]
        [Route("TC/AddOrUpdateCourseManage")]
        public async Task AddOrUpdateCourseManage([FromBody] CourseManageEntity input)
        {
            await _courseTrainTaskService.AddOrUpdateCourseManage(input);
        }

        /// <summary>
        /// 更新培训课程状态
        /// </summary>
        /// <param name="courseManageId">主键</param>
        /// <param name="status">状态</param>
        [HttpGet]
        [Route("TC/UpdateCourseManageStatus/{courseManageId}/{status}")]
        public async Task UpdateCourseManageStatus([FromRoute] string courseManageId, int status)
        {
            await _courseTrainTaskService.UpdateCourseManageStatus(courseManageId, status);
        }

        /// <summary>
        /// 删除培训课程数据
        /// </summary>
        /// <param name="courseManageId">主键</param>
        [HttpDelete]
        [Route("TC/CourseManage/{courseManageId}")]
        public async Task DeleteCourseManage([FromRoute] string courseManageId)
        {
            await _courseTrainTaskService.DeleteCourseManage(courseManageId);
        }

        /// <summary>
        /// 培训课程数据 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TC/ExportCourseManageResultAsync")]
        public async Task<XlsxFileResult<GetCourseManageOutput>> ExportCourseManageResultAsync([FromBody] GetCourseItemInput input)
        {
            var rst = await _courseTrainTaskService.ExportCourseManageResultAsync(input);
            return new XlsxFileResult<GetCourseManageOutput>(rst, "导出Excel");
        }

        /// <summary>
        /// 获取课程下拉选项
        /// </summary>
        [HttpGet]
        [Route("TC/GetManageOptions")]
        public async Task<List<ItemPairDto>> GetManageOptions()
        {
            return await _courseTrainTaskService.GetManageOptions();
        }
        #endregion
        #region 发送邮件
        /// <summary>
        /// 发起邮箱
        /// </summary>
        /// <param name="id">任务单号</param>
        /// <param name="type">邮件类型</param>
        /// <returns>任务单详情</returns>
        [HttpGet]
        [Route("TC/SendCourseEmail")]
        public async void SendCourseEmail(CourseTrainEmailEnum type, string id)
        {
            await _courseTrainTaskSyncJobService.SendCourseEmail(type, id);
        }

        /// <summary>
        /// 自动任务测试
        /// </summary>
        /// <returns>任务单详情</returns>
        [HttpGet]
        [Route("TC/CourseTrainTaskJob")]
        public async void CourseTrainTaskJob()
        {
            await _courseTrainTaskSyncJobService.CourseTrainTaskJob();
        }
        #endregion
        #region 报表
        /// <summary>
        /// 国内培训计划流程表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("Report1/GetList")]
        public async Task<PagedResultPowerDto<ExportCourseOutput>> ReportResult(CourseReportDto.ReportSearchDto input)
        {
            return await _courseTrainTaskService.GetReportResult(input);
        }

        /// <summary>
        /// 国内培训计划流程表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("Report1/Download")]
        public async Task<XlsxFileResult<ExportCourseOutput>> ResultDownloadAsync([FromBody] ReportSearchDto input)
        {
            input.PageSize = int.MaxValue;
            var rst = (await _courseTrainTaskService.GetReportResult(input)).Items.ToList();
            return new XlsxFileResult<ExportCourseOutput>(rst, "国内培训计划流程导出");
        }

        /// <summary>
        /// 报销费用统计表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("Report2/GetList")]
        public async Task<PagedResultPowerDto<CourseTrainTaskReportDto>> ExpenseReportResult(CourseReportDto.ReportSearchDto input)
        {
            return await _courseTrainTaskService.GetExpenseReportResult(input);
        }

        /// <summary>
        /// 报销费用统计表导出
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("Report2/Download")]
        public async Task<XlsxFileResult<CourseTrainTaskReportDto>> ExpenseReportDownloadResult([FromBody] ReportSearchDto input)
        {
            input.PageSize = int.MaxValue;
            var rst = (await _courseTrainTaskService.GetExpenseReportResult(input)).Items.ToList();
            return new XlsxFileResult<CourseTrainTaskReportDto>(rst, "报销费用统计表导出");
        }
        #endregion

    }
}